package com.birdcage.gamemanagers;

import android.util.Log;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.birdcage.goldminer.Game;

///Singleton
///It will manage all game utility.
public class Utility
{
    ///Singleton Implement
    static public Utility GetInstance()
    {
        if (m_instance == null)
        {
            m_instance = new Utility();
        }       
        return m_instance;
    }
    private Utility(){};
    private static Utility m_instance = null;   


    ///Public Method
    public void Update()
    {
        if (Gdx.input.isTouched())
        {
            Log.i("TouchPos", "x = " + Gdx.input.getX()+", y = " + Gdx.input.getY()+"\n") ;
        }
        // Hide all graphics and show debug graphics.
        if (Gdx.input.isKeyPressed(Keys.KEYCODE_Z))
        {
            GraphicsManager pGraphicsManager = GraphicsManager.GetInstance();
            pGraphicsManager.SetEnable(!pGraphicsManager.GetEnable());
            Game.GetInstance().SetDebugVisible(!pGraphicsManager.GetEnable());
        }
    }
    
    public void DrawRect(float x, float y, float width, float height, int r, int g, int b, int a)
    {
        GeometryRenderer.GetInstance().Begin();
        GeometryRenderer.GetInstance().Color4(r, g, b, a);
        GeometryRenderer.GetInstance().Vertex2(x, y);
        GeometryRenderer.GetInstance().Color4(r, g, b, a);
        GeometryRenderer.GetInstance().Vertex2(x + width, y);
        GeometryRenderer.GetInstance().Color4(r, g, b, a);
        GeometryRenderer.GetInstance().Vertex2(x + width, y + height);
        GeometryRenderer.GetInstance().Color4(r, g, b, a);
        GeometryRenderer.GetInstance().Vertex2(x, y + height);
        GeometryRenderer.GetInstance().End();        
    }
}
